home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000126_icon-group-sender_Mon Oct 30 13:11:36 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9UKBR606127
for icon-group-addresses; Mon, 30 Oct 2000 13:11:27 -0700 (MST)
Message-Id: <200010302011.e9UKBR606127@baskerville.CS.Arizona.EDU>
Date: Mon, 30 Oct 2000 09:24:12 -0700
From: Steve Wampler <swampler@noao.edu>
X-Accept-Language: en
To: Atle <trollet@skynet.be>
CC: icon-group@cs.arizona.edu
Subject: Re: Yet another Newbie question....
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2278
Atle wrote:
>
> symbiot@my-deja.com wrote:
>
> > Hi,
> >
> > And thanks in advance to all who have been helping me thru this
> > learning curve of getting started in ICON.
> >
> > My present problem is trying to write a rountine that counts only
> > letters in text and skips blanks, numbers, punctuation, etc.
> >
> > I tried....
> >
> > if member(&letters,line[index]) then totalcount +:= 1
> >
> > ...but for some unexplicable reason, it barfed on the very first
> > character with
> >
> > set or table expected.
> > Offending value &letters
> >
> > Isn't &letters a cset? You can use it in other "set" functions....can't
> > you? What am I missing?
> >
> > Assistance appreciated!
> I have no idea if this gets you anywhere, but since there doesn't seem to be many pros out there to help either of us right now ...
Hmmm, I saw several replies, but perhaps they weren't as clear as they could be:
member(s, e) requires that s be either an Icon set or an Icon table. A cset is
neither, hence the error (maybe member should also accept a cset as a first
argument, as it does in Unicon, but it doesn't).
A simple way to see if a character is contained in a cset is to use set
intersection
and see if the intersection contains anything, as in:
if *(cset1 ** "a") > 0 then write("a is in ",cset1)
else write("a is not in ",cset1)
Note that this can be used to efficiently check to see an any of several
characters
are in the cset *simultaneously*, as in:
if *(cset1 ** string1) > 0 then write(string1," has characters found in
",cset1)
else write(string1," has no characters from
",cset1)
In general, the set operations ++, **, and -- can be used very effectively with
csets. As a final example, consider the problem of finding all the characters
in string string1 that do *not* appear in cset cset1:
write("The characters in ",string1," not found in ",cset1," are
'",string1--cset1,"'")
Does this help? The original problem isn't related to the differences between
strings
and csets (since Icon will coerce one to the other as needed), but with assuming
that
an Icon cset can be used anywhere an Icon set can be used.
--
Steve Wampler- SOLIS Project, National Solar Observatory
swampler@noao.edu